<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>盛最多水的容器 - 算法详解</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
        }
        .serif-font {
            font-family: 'Noto Serif SC', serif;
        }
        .gradient-text {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-4px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
        }
        .code-block {
            background: #1e1e1e;
            border-radius: 12px;
            overflow: hidden;
        }
        .code-header {
            background: #2d2d2d;
            padding: 12px 20px;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }
        .code-dots {
            display: flex;
            gap: 8px;
        }
        .dot {
            width: 12px;
            height: 12px;
            border-radius: 50%;
        }
        .dot-red { background: #ff5f56; }
        .dot-yellow { background: #ffbd2e; }
        .dot-green { background: #27c93f; }
        pre {
            margin: 0;
            padding: 20px;
            overflow-x: auto;
        }
        code {
            font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
            color: #d4d4d4;
            line-height: 1.6;
        }
        .keyword { color: #c586c0; }
        .function { color: #dcdcaa; }
        .number { color: #b5cea8; }
        .string { color: #ce9178; }
        .comment { color: #6a9955; }
        .operator { color: #d4d4d4; }
        .builtin { color: #4ec9b0; }
        @keyframes float {
            0%, 100% { transform: translateY(0px); }
            50% { transform: translateY(-20px); }
        }
        .float-animation {
            animation: float 6s ease-in-out infinite;
        }
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 2rem 0;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-6">
        <div class="max-w-6xl mx-auto">
            <div class="text-center">
                <div class="inline-flex items-center bg-white bg-opacity-20 rounded-full px-4 py-2 mb-6">
                    <i class="fas fa-code mr-2"></i>
                    <span class="text-sm font-medium">LeetCode 经典算法题</span>
                </div>
                <h1 class="text-5xl md:text-6xl font-bold mb-6 serif-font">盛最多水的容器</h1>
                <p class="text-xl md:text-2xl text-gray-100 max-w-3xl mx-auto leading-relaxed">
                    探索双指针算法的优雅之处，用 O(n) 的时间复杂度解决看似复杂的问题
                </p>
                <div class="mt-10 flex justify-center space-x-6">
                    <div class="text-center">
                        <div class="text-3xl font-bold">O(n)</div>
                        <div class="text-sm opacity-80">时间复杂度</div>
                    </div>
                    <div class="text-center">
                        <div class="text-3xl font-bold">O(1)</div>
                        <div class="text-sm opacity-80">空间复杂度</div>
                    </div>
                    <div class="text-center">
                        <div class="text-3xl font-bold">中等</div>
                        <div class="text-sm opacity-80">难度等级</div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="max-w-6xl mx-auto px-6 py-16">
        <!-- Problem Description -->
        <section class="mb-16">
            <div class="bg-white rounded-2xl shadow-lg p-8 card-hover">
                <div class="flex items-center mb-6">
                    <div class="w-12 h-12 bg-purple-100 rounded-lg flex items-center justify-center mr-4">
                        <i class="fas fa-question-circle text-purple-600 text-xl"></i>
                    </div>
                    <h2 class="text-3xl font-bold">题目描述</h2>
                </div>
                <p class="text-lg text-gray-700 leading-relaxed mb-6">
                    给定 n 个非负整数 a₁, a₂, ..., aₙ，每个数代表坐标中的一个点 (i, aᵢ)。在坐标内画 n 条垂直线，垂直线 i 的两个端点分别是 (i, aᵢ) 和 (i, 0)。找出其中的两条线，使得它们与 x 轴共同构成的容器能够容纳最多的水。
                </p>
                <div class="bg-gray-50 rounded-xl p-6">
                    <div class="flex items-center mb-3">
                        <i class="fas fa-lightbulb text-yellow-500 mr-2"></i>
                        <span class="font-semibold text-gray-800">示例</span>
                    </div>
                    <p class="text-gray-700">
                        输入：[1, 8, 6, 2, 5, 4, 8, 3, 7]<br>
                        输出：49<br>
                        <span class="text-sm text-gray-600">解释：选择高度为 8 和 7 的两条线，面积为 min(8, 7) × (8 - 1) = 49</span>
                    </p>
                </div>
            </div>
        </section>

        <!-- Visual Representation -->
        <section class="mb-16">
            <div class="bg-white rounded-2xl shadow-lg p-8">
                <h3 class="text-2xl font-bold mb-6 flex items-center">
                    <i class="fas fa-chart-bar text-purple-600 mr-3"></i>
                    算法可视化
                </h3>
                <div class="mermaid">
                    graph LR
                        A[开始] --> B[左指针 = 0<br/>右指针 = n-1]
                        B --> C{左指针 < 右指针?}
                        C -->|是| D[计算当前面积]
                        D --> E[更新最大面积]
                        E --> F{height[左] < height[右]?}
                        F -->|是| G[左指针右移]
                        F -->|否| H[右指针左移]
                        G --> C
                        H --> C
                        C -->|否| I[返回最大面积]
                </div>
            </div>
        </section>

        <!-- Core Concepts -->
        <section class="mb-16">
            <div class="grid md:grid-cols-2 gap-8">
                <div class="bg-white rounded-2xl shadow-lg p-8 card-hover">
                    <div class="flex items-center mb-6">
                        <div class="w-12 h-12 bg-blue-100 rounded-lg flex items-center justify-center mr-4">
                            <i class="fas fa-brain text-blue-600 text-xl"></i>
                        </div>
                        <h3 class="text-2xl font-bold">核心考点</h3>
                    </div>
                    <div class="space-y-4">
                        <div class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-3"></i>
                            <div>
                                <h4 class="font-semibold text-lg">双指针技巧</h4>
                                <p class="text-gray-600">从两端向中间收缩，避免暴力枚举</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-3"></i>
                            <div>
                                <h4 class="font-semibold text-lg">贪心策略</h4>
                                <p class="text-gray-600">每次移动较短边，寻找更大面积的可能</p>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="bg-white rounded-2xl shadow-lg p-8 card-hover">
                    <div class="flex items-center mb-6">
                        <div class="w-12 h-12 bg-green-100 rounded-lg flex items-center justify-center mr-4">
                            <i class="fas fa-rocket text-green-600 text-xl"></i>
                        </div>
                        <h3 class="text-2xl font-bold">算法优势</h3>
                    </div>
                    <div class="space-y-4">
                        <div class="flex items-start">
                            <i class="fas fa-bolt text-yellow-500 mt-1 mr-3"></i>
                            <div>
                                <h4 class="font-semibold text-lg">高效性能</h4>
                                <p class="text-gray-600">线性时间复杂度，一次遍历解决问题</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <i class="fas fa-memory text-purple-500 mt-1 mr-3"></i>
                            <div>
                                <h4 class="font-semibold text-lg">空间优化</h4>
                                <p class="text-gray-600">仅使用常数额外空间，内存友好</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Solution -->
        <section class="mb-16">
            <div class="bg-white rounded-2xl shadow-lg overflow-hidden">
                <div class="p-8">
                    <div class="flex items-center mb-6">
                        <div class="w-12 h-12 bg-purple-100 rounded-lg flex items-center justify-center mr-4">
                            <i class="fas fa-code text-purple-600 text-xl"></i>
                        </div>
                        <h3 class="text-2xl font-bold">解题思路</h3>
                    </div>
                    <div class="space-y-4 text-lg text-gray-700">
                        <div class="flex items-start">
                            <span class="inline-flex items-center justify-center w-8 h-8 bg-purple-100 text-purple-600 rounded-full font-bold mr-4 flex-shrink-0">1</span>
                            <p>使用两个指针 <code class="bg-gray-100 px-2 py-1 rounded text-sm">left</code> 和 <code class="bg-gray-100 px-2 py-1 rounded text-sm">right</code> 从数组两端向中间移动</p>
                        </div>
                        <div class="flex items-start">
                            <span class="inline-flex items-center justify-center w-8 h-8 bg-purple-100 text-purple-600 rounded-full font-bold mr-4 flex-shrink-0">2</span>
                            <p>每次计算当前面积：宽度 × 高度，其中宽度为 <code class="bg-gray-100 px-2 py-1 rounded text-sm">right - left</code>，高度为 <code class="bg-gray-100 px-2 py-1 rounded text-sm">min(height[left], height[right])</code></p>
                        </div>
                        <div class="flex items-start">
                            <span class="inline-flex items-center justify-center w-8 h-8 bg-purple-100 text-purple-600 rounded-full font-bold mr-4 flex-shrink-0">3</span>
                            <p>移动较短的指针，因为面积受限于较短边，移动较长边不会得到更大面积</p>
                        </div>
                        <div class="flex items-start">
                            <span class="inline-flex items-center justify-center w-8 h-8 bg-purple-100 text-purple-600 rounded-full font-bold mr-4 flex-shrink-0">4</span>
                            <p>持续更新最大面积，直到两指针相遇</p>
                        </div>
                    </div>
                </div>

                <!-- Code Section -->
                <div class="code-block">
                    <div class="code-header">
                        <div class="flex items-center">
                            <div class="code-dots">
                                <div class="dot dot-red"></div>
                                <div class="dot dot-yellow"></div>
                                <div class="dot dot-green"></div>
                            </div>
                            <span class="ml-4 text-gray-400 text-sm">solution.py</span>
                        </div>
                        <div class